function EditInitFun() {
	return {
		initConfig(vm, taskManager, objName, callBack) {
			const init_job = taskManager.createJob('initConfig_edit');

			taskManager.addAction(init_job, {
				type: 'job',
				async: true,
				execution: EditInitFun().initJobFun(vm, taskManager, objName, callBack)
			});

			taskManager.addJob(init_job);

		},
		initJobFun(vm, taskManager, objName, callBack) {
			const init_job_son = taskManager.createJob('initConfig_son_edit');

			taskManager.addAction(init_job_son, {
				type: 'function',
				async: true,
				execution: () => {
					return new Promise((resolve, reject) => {
						vm.Request.request("getAPPRoleColFunByRoleID", {
							moduleName: vm.detailName,
							moduleType: 'formdetail',
						}, (res) => {
							if (res.status == 200) {
								vm.APPRoleCol = res.data.ds;
								resolve();
							};
						}, (err) => {
							console.log(err);
						})
					})
				}
			});

			taskManager.addAction(init_job_son, {
				type: 'job',
				async: true,
				execution: (() => {
					const init_job_son_child = taskManager.createJob('initConfig_son_child_edit');


					taskManager.addAction(init_job_son_child, {
						type: 'function',
						async: true,
						execution: () => {
							return new Promise((resolve, reject) => {
								vm.Request.requestByUrl(
									'/AppFormDetail/GetDataByName', {
										objName: objName
									},
									function(ret) {
										let data = {};
										console.log(111222);
										data = vm.$utils.deepClone(ret);
										console.log(data);
										vm.globalData = vm.$utils.deepClone(ret);
										vm.physicalTableName = ret.ds[0]
											.physicalTableName;

										resolve();
									})
							})
						}
					})
					taskManager.addAction(init_job_son_child, {
						type: 'function',
						async: true,
						execution: () => {
							return new Promise((resolve, reject) => {
								vm.Request.requestByUrl(
									'/AppFormDetail/GetDataByName', {
										objName: objName
									},
									function(ret) {
										console.log(333);
										resolve();
									})
							})
						}
					})
					return init_job_son_child

				})()
			});
			taskManager.addAction(init_job_son, {
				type: 'function',
				async: true,
				execution: () => {
					console.log(33333);
				}
			})


			// taskManager.addAction(init_job_son, {
			// 	type: 'job',
			// 	async: true,
			// 	execution: vm.keyName && vm.keyValue ? EditInitFun().handleEditItem(vm, taskManager, objName,
			// 		callBack) : EditInitFun().handleAddItem(vm, taskManager, objName, callBack)

			// });

			return init_job_son;

		},

		handleAddItem(vm, taskManager, objName, callBack) { // 新增逻辑
			const init_job_son_child = taskManager.createJob('initConfig_son_child_edit');
			taskManager.addAction(init_job_son_child, {
				type: 'function',
				async: false,
				execution: () => {
					vm.isUpdate = false;
					console.log(111);
				}
			});

			taskManager.addAction(init_job_son_child, {
				type: 'job',
				async: true,
				execution: (() => {
					const init_job_son_childByData = taskManager.createJob(
						'initConfig_son_childByData_edit');

					let data = vm.$utils.deepClone(vm.globalData);

					console.log(123);
					if (!vm.$utils.isEmpty(data.ds[0].formDesignConfig)) {
						console.log(456);
						taskManager.addAction(init_job_son_childByData, {
							type: 'function',
							async: false,
							execution: () => {
								console.log(567);
								var newFormData = {};
								var designControls = JSON.parse(data.ds[0]
									.formDesignConfig);
								console.log(designControls);
								for (var i = 0; i < designControls.length; i++) {
									if (designControls[i].baseProperty.defaultValue &&
										designControls[i].baseProperty.defaultValue.indexOf(
											'@') <
										0) {
										newFormData[designControls[i].baseProperty
												.controlName] =
											vm.getSYDefaultValue(designControls[i]
												.baseProperty
												.defaultValue);
									} else if (designControls[i].baseProperty
										.defaultValue &&
										designControls[i].baseProperty.defaultValue.indexOf(
											'@') >=
										0) {
										var userInfo = vm.getSYDefaultValue(designControls[
												i]
											.baseProperty.defaultValue);
										newFormData[designControls[i].baseProperty
												.controlName] =
											userInfo.P_UserID;
										newFormData[designControls[i].baseProperty
											.controlName +
											'_show'] = userInfo.P_UserName;
									} else {
										newFormData[designControls[i].baseProperty
												.controlName] =
											"";
									}
								}
								vm.formData = newFormData;
								if (vm.origin == 'draft') { // 来源-草稿箱
									vm.formData = Object.assign(vm.formData, vm.$store.state
										.MenuDetail.dataInfo.formData);

								} else {

									// 给待办用的，暂时这么写
									if (vm.childListData.length) {
										if (vm.childListData.length) {
											vm.formData[vm.waitKeyName] = vm.childListData[
													0]
												[vm.waitKeyName]
										}
									}
								}
							}
						})

						taskManager.addAction(init_job_son_childByData, {
							type: 'function',
							async: false,
							execution: () => {
								vm.tableConfig({
									childFormList: JSON.parse(data.ds[0]
										.childFormsConfig),
									formDesign: JSON.parse(data.ds[0]
										.formDesignConfig),
									physicalTableName: data.ds[0].physicalTableName,
									workList: JSON.parse(data.ds[0].worksConfig),
									crudList: JSON.parse(data.ds[0].crudConfig),
									importConfig: JSON.parse(data.ds[0]
										.importConfig),
									scanConfig: data.ds[0].scanConfig,
									onReadyCallBack: data.ds[0].onReadyCallBack,
									approvalConfig: {
										isEnableApproval: false
									},
								});
							}
						})
					}

					return init_job_son_childByData

				})()
			})


			return init_job_son_child;

		},
		handleEditItem(vm, taskManager, objName, callBack) { // 编辑逻辑
			vm.isUpdate = true;

		}



	}
}

export default EditInitFun();